import java.util.Properties;

public class DriverCreateCustomer {

	Properties display = new Properties();

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		DriverCreateCustomer driver = new DriverCreateCustomer();
	}

	public DriverCreateCustomer() {
		Worker worker;
		TransactionManager manager;
		Task task;
		loadDisplay();
		AccountRepresentation representation;

		// Create a new customer
		task = new Task(Constants.NEW_CUSTOMER_ACCOUNT);
		task.addParameter(Constants.PIN, "1234");
		task.addParameter(Constants.NAME, "Sample Customer");
		task.addParameter(Constants.DOB, "750411");
		task.addParameter(Constants.SSN, "987654321");
		task.addParameter(Constants.STREET, "4400 University Drive");
		task.addParameter(Constants.CITY, "Fairfax");
		task.addParameter(Constants.ZIP, "22030");
		task.addParameter(Constants.STATE, "VA");
		task.addParameter(Constants.VOICEMAIL, "Y");
		task.addParameter(Constants.CALLER_ID, "Y");
		task.addParameter(Constants.THREE_WAY, "N");
		task.addParameter(Constants.DISTANCE_PROVIDER, "Sprint");

		try {
		manager = new TransactionManager();

		worker = manager.getWorker();

		representation = worker.request(task);

		if (representation.getSuccessful()) { // everything was Ok, so display
			display.putAll(representation.getUpdates()); // load all updated
															// values
			display.list(System.out); // display with updates
		}

		else {// there was an error with the request, so errors should be
				// displayed
			System.out.println(representation.getErrorMessages()); // display
																	// error
		}
		}
		catch(Exception e) {
			e.printStackTrace(System.err);
		}
	}

	/**
	 * Initialize all of the values that will be displayed by Swing objects
	 */
	private void loadDisplay() {
		display = new Properties();

		display.setProperty(Constants.PIN, "");
		display.setProperty(Constants.NAME, "");
		display.setProperty(Constants.DOB, "");
		display.setProperty(Constants.SSN, "");
		display.setProperty(Constants.STREET, "");
		display.setProperty(Constants.ZIP, "");
		display.setProperty(Constants.CITY, "");
		display.setProperty(Constants.STATE, "");
		display.setProperty(Constants.VOICEMAIL, "");
		display.setProperty(Constants.CALLER_ID, "");
		display.setProperty(Constants.THREE_WAY, "");
		display.setProperty(Constants.DISTANCE_PROVIDER, "");
		display.setProperty(Constants.ACCOUNT_NUMBER, "");
		display.setProperty(Constants.PHONE0, "");
		display.setProperty(Constants.PHONE1, "");
		display.setProperty(Constants.PHONE2, "");
		display.setProperty(Constants.PHONE3, "");

		display.setProperty(Constants.TROUBLE0, "");
		display.setProperty(Constants.TROUBLE1, "");
		display.setProperty(Constants.TROUBLE2, "");
		display.setProperty(Constants.TROUBLE3, "");

		display.setProperty(Constants.SERVICE0, "");
		display.setProperty(Constants.SERVICE1, "");
		display.setProperty(Constants.SERVICE2, "");
		display.setProperty(Constants.SERVICE3, "");

	}

}
